package com.googlecode.linkmein.domain;

import com.google.gdata.data.spreadsheet.CustomElementCollection;
import com.google.gdata.data.spreadsheet.ListEntry;
import static com.googlecode.linkmein.utils.Util.defaultString;

import java.util.ArrayList;
import java.util.List;

public class Contacts extends ArrayList<Contact> {
    public Contacts() {

    }

    public Contacts(List<ListEntry> entries) {
        for (ListEntry entry : entries) {
            CustomElementCollection elements = entry.getCustomElements();
            List<String> tags = new ArrayList(elements.getTags());

            String realName = defaultString(elements.getValue(tags.get(0)));
            String goodleId = defaultString(elements.getValue(tags.get(2)));
            String cellphone = defaultString(elements.getValue(tags.get(3)));
            String yahooId = defaultString(elements.getValue(tags.get(4)));
            String msn = defaultString(elements.getValue(tags.get(5)));
            String skypeId = defaultString(elements.getValue(tags.get(6)));
            String blog = defaultString(elements.getValue(tags.get(7)));
            Contact contact = Contact.get(realName, goodleId, cellphone, yahooId, msn, skypeId, blog);
            this.add(contact);
        }
    }

    public Contacts(Contact... employees) {
        for (Contact employee : employees) {
            this.add(employee);
        }
    }
}
